package final2107.day11;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class NewDate {
    public static void main(String[] args) {
//        LocalDateTime time = LocalDateTime.now();
//        System.out.println(time);
//
//        //日期类型转换为某种格式的字符串
//        DateTimeFormatter formatter =
//                DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//
//        String dateStr = formatter.format(time);
//        System.out.println(dateStr);

        //String-->LocalDateTime
        String date = "2020-12-12 12:12:12";
        DateTimeFormatter formatter =
                DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

        LocalDateTime currentTime = LocalDateTime.parse(date,formatter);
        System.out.println(currentTime);
    }
}
